package com.ghca.myinfo3.project.controller;

import com.ghca.myinfo3.common.eneity.BJUIPage;
import com.ghca.myinfo3.project.entity.BidProject;
import com.ghca.myinfo3.project.entity.Project;
import com.ghca.myinfo3.project.service.IProjectService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by Administrator on 2016/12/20.
 */
@Controller
@RequestMapping("/project")
public class ProjectController {


    @Resource
    private IProjectService projectService;



    @RequestMapping("/bid")
    public String bid() {
        return "project/bid";
    }

    @RequestMapping("/{status}/list")
    @ResponseBody
    public BJUIPage<Project> list(@PathVariable("status") String status, @RequestParam(value = "pageCurrent", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer limit) {
        if(page==null) page=0;
        if(limit==null) limit = 15;
        Page<Project> projects = projectService.findAll(new PageRequest(page - 1, limit), 1);
        BJUIPage<Project>  bjuiPage = new BJUIPage<>();
        bjuiPage.setPage(projects);
        return bjuiPage;
    }
}
